#version 430 core

#define GRID_SIZE_X 64.f
#define GRID_SIZE_Y 64.f
#define MIN_TRANSFER_LEVEL -10
#define MAX_TRANSFER_LEVEL 10

layout(binding=0) uniform sampler2D levelSetTexture;
layout(binding=1) uniform sampler1D transferTexture;

in vec2 v_Position;

layout(location=0) out vec4 outColor;

void main(void)
{
	vec2 texCoords = v_Position * vec2(GRID_SIZE_X/(GRID_SIZE_X+1.f), GRID_SIZE_Y/(GRID_SIZE_Y+1.f)) + vec2(0.5f/(GRID_SIZE_X+1), 0.5f/(GRID_SIZE_Y+1));
	float level = texture(levelSetTexture, texCoords).r;
	float transferTexCoord = (level - MIN_TRANSFER_LEVEL) * (1.f/(MAX_TRANSFER_LEVEL - MIN_TRANSFER_LEVEL));
	outColor = texture(transferTexture, transferTexCoord);
}